import java.util.Date;
import java.util.concurrent.*;

public class hanglie {

    public int maxCount(int m, int n, int[][] ops) {


        if (ops==null||ops.length==0){
            return m*n;
        }

        int hang=ops[0][0];
        for (int i = 1; i < m; i++) {
            hang=Math.min(hang,ops[i][0]);
        }
        int lie=ops[0][1];
        for (int i = 1; i < n; i++) {
            lie=Math.min(lie,ops[i][1]);
        }

        return hang*lie;
    }

    public static void main(String[] args) throws Exception{

        long startTime = System.currentTimeMillis();
        System.out.println();
//        ExecutorService executorService = Executors.newSingleThreadExecutor();

//        jdk
        ThreadFactory defaultThreadFactory = Executors.defaultThreadFactory();
        //使用guava的线程池工厂
//        ThreadFactory.

        //ArrayBlockingQueue 长度为1 任务拒绝了 如何在此尝试呢?
        ExecutorService executorService = new ThreadPoolExecutor(1,1,0, TimeUnit.SECONDS, new ArrayBlockingQueue(10),defaultThreadFactory,new ThreadPoolExecutor.AbortPolicy());

        executorService.submit(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(2000);
                    System.out.println("ok1！");
                }catch (Exception e){}

                long endTime = System.currentTimeMillis();
                System.out.println("1花费了:"+(int)((endTime-startTime)/1000)+"秒");
            }
        });

        executorService.submit(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(3000);
                    System.out.println("ok2！");
                }catch (Exception e){}

                long endTime = System.currentTimeMillis();
                System.out.println("2花费了:"+(int)((endTime-startTime)/1000)+"秒");
            }
        });
        executorService.submit(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(3000);
                    System.out.println("ok3！");
                }catch (Exception e){}

                long endTime = System.currentTimeMillis();
                System.out.println("3花费了:"+(int)((endTime-startTime)/1000)+"秒");
            }
        });

        System.out.println("main--1");
        executorService.shutdown();
        System.out.println("main--2");
    }
}


